[pull] main from triggerdotdev:main#221
Merged
Merged
Conversation
…ubtasks (#3936) ## Summary Three fixes that bring custom agent loops (`chat.customAgent` hand-rolled loops and `chat.createSession`) up to the behavior `chat.agent` users already get, and that the docs already promise: - **Continuation runs no longer replay already-answered messages.** A chat continuing after a cancel, crash, or upgrade re-delivered every prior user message into the loop's first wait, so the model re-answered an old message while the real new one had to arrive via steering. The `.in` resume cursor is now seeded before any listener attaches, using the same boot logic as `chat.agent`. - **Mid-stream steering no longer wipes the in-flight response.** `chat.pipeAndCapture` (also backing `turn.complete()`) streamed without a server-generated message id, so a `prepareStep` injection regenerated the assistant id mid-stream and the frontend replaced the partial message, discarding everything streamed before the injection. - **Task-backed tools now work from custom agent loops.** A child task triggered via `ai.toolExecute` failed with "chat.agent session handle is not initialized" because the parent's chatId only threaded from the per-turn context that hand-rolled loops never set. It now falls back to the session handle the `chat.customAgent` wrapper binds at run boot, so children can stream progress into the chat with `chat.stream.writer({ target: "root" })` (the documented sub-agent pattern). ## Root cause on the replay fix Attaching any `.in` listener (`chat.createStopSignal`, `chat.messages.on`, the first wait) opens the SSE tail with `Last-Event-ID` taken from the seq cursor at attach time. Custom loops attached before any cursor existed, so S2 replayed from seq 0. The fix resolves the cursor from the latest turn-complete header and seeds both manager cursors (`setLastSeqNum` drives the SSE resume point, `setLastDispatchedSeqNum` gates waiter dispatch) before attach; `chat.createSession` now creates its stop signal lazily on the first iteration, after the seed. Seeding only the first cursor after attach does not work, which is why the earlier attempt at this was reverted. All three were reproduced red-green against the references ai-chat project: the replay repro showed the continuation wait consuming a stale message in 403ms with the real message arriving via steering injection; post-fix the wait consumes the real message directly with no injection. Steering now preserves the full in-flight response, and the deepResearch sub-agent streams its progress parts into a raw-loop parent. Existing behavior verified unchanged: full SDK unit suite, `chat.agent` steering, and stop-then-continue on `chat.createSession`.
…3937) ## Summary `@trigger.dev/sdk` now ships the Trigger.dev agent skills and a curated snapshot of the docs those skills cite. The skills that `trigger skills` installs into your coding agent are thin pointers that read this bundled content from `node_modules`, so the guidance always matches the SDK version installed in your project. Previously the full skill text was copied into your repo at install time and went stale until you reinstalled after an upgrade. ## How it works The SDK's `files[]` now includes `skills/` (the full skill text) and `docs/` (a curated snapshot generated at build time). The docs manifest is derived from each skill's own `sources:` frontmatter, so a skill only ships the docs it references, and a skill that cites a missing doc fails the build. The CLI installs thin skills whose body points the agent at `node_modules/@trigger.dev/sdk/skills/<name>/SKILL.md` and `node_modules/@trigger.dev/sdk/docs/`. They keep the high-value "Common mistakes" anti-patterns inline so the trigger and the guardrails survive even if the agent does not follow the pointer. `getting-started` stays self-contained in the CLI because it runs before the SDK is installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )
This change is